﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Wicture.DbRESTFul;
using Wicture.DbRESTFul.Rpc.Client;
using Wicture.QPZS.EPC.Repository;
using Wicture.QPZS.EPC.Services.UserAuth.Base;

namespace Wicture.QPZS.EPC.Services.UserAuth
{
    public class EpcUserAuthProcessor : BaseUserAuthProcessor
    {
        public override void HandleVinQueryResult(RpcRepository repository, JObject vinInfo)
        {
            string vin = vinInfo.Value<string>("vin");
            string brandCode = vinInfo.Value<string>("brandCode");
            string modelName = string.IsNullOrEmpty(vinInfo.Value<string>("fullName")) ? vinInfo.Value<string>("name") : vinInfo.Value<string>("fullName");
            QueryProcessor.Instance.BuildVinResult(repository, brandCode, vin, modelName);
        }

        public override void PartListPreProcess(EpcRepository repository, string brandCode)
        {
            QueryProcessor.Instance.PartListPreProcess(repository, brandCode);
        }
        public override void HandlePartListResult(RpcRepository repository, JArray data, string brandCode)
        {
            QueryProcessor.Instance.BuildPartListResult(repository, data, brandCode);
        }
        public override void HandlePartDetailResult(IDbRESTFulRepository repository, JObject data, string brandCode)
        {
            QueryProcessor.Instance.BuildPartDetailResult(repository, data, brandCode);
        }
        public override void CheckSearchPartTimes(IDbRESTFulRepository repository, string brandCode, string keyword)
        {
            QueryProcessor.Instance.CheckSearchPartTimes(repository, brandCode, keyword);
        }
        public override void CheckSearhPartCounts(IDbRESTFulRepository repository, int times, string brandCode)
        {
            QueryProcessor.Instance.CheckSearhPartCounts(repository, times, brandCode);
        }
        public override void BuildPartSearchResult(IDbRESTFulRepository repository, JObject data)
        {
            QueryProcessor.Instance.BuildPartSearchResult(repository, data);
        }
    }
}
